//Page 357
//Demonstrates mem_fun_ref(...) with string::empty().
#include <algorithm>
#include <cstddef>
#include <fstream>
#include <functional>
#include <string>
#include <vector>
#include <iterator>
#include <iostream>

using namespace std ;

typedef vector<string>::iterator LSI ;

int main(int argc, char * argv[])
{
	char * fname = "Blanks.txt";
	if(argc > 1) fname = argv[1] ;
	ifstream inf(fname) ;
	vector<string> vs;
	string s;

	while(getline(inf, s))
		vs.push_back(s);

	LSI lsi = find_if(vs.begin(), vs.end(), mem_fun_ref(&string::empty)) ;

	while(lsi != vs.end())
	{
		*lsi = "A blank line" ;
		lsi = find_if(vs.begin(), vs.end(), mem_fun_ref(&string::empty));
	}

	copy(vs.begin(), vs.end(), ostream_iterator<string>(cout, "\n")) ;

	return 0 ;
}
